<% include ../header %>
        <div class="row-fluid">
        <% if(!operate.success&&operate.msg.length>0) {%>
        <div class="alert alert-danger"><a class="close" data-dismiss="alert" href="#">&times;</a><%= operate.msg%></div>
        <% }%>
        <form class="form-horizontal" method="post" action="">
            <% if(edit){ %>
            <h3>编辑用户信息</h3>
            <% }else{ %>
            <h3>创建新用户</h3>
            <% } %>
            <hr/>          

            <div class="form-group">
                <label class="col-md-2 control-label" for="name">姓名:</label>
                <div class="col-md-4">
                    <input type="text" class="form-control" id="name" name="name"
                    <% if(edit){ %>
                    value="<%= editUser.name %>"
                    <% }else{ %>
                    value=""
                    <% } %>> 
                </div>
            </div>

            <div class="form-group">
                <label class="col-md-2 control-label" for="mail">邮箱:</label>
                <div class="col-md-4">
                    <input type="text" class="form-control" id="mail" name="mail"
                    <% if(edit){ %>
                    value="<%= editUser.mail %>"
                    <% }else{ %>
                    value=""
                    <% } %>> 
                </div>
            </div>

            <div class="form-group">
                <label class="col-md-2 control-label" for="isAdmin">权限:</label>
                <div class="col-md-4">
                    <select class="form-control" name="isAdmin" id="isAdmin">
                        <option value="1" 
                        <% if(edit&&editUser.isAdmin==1){ %>
                        selected="selected"
                        <% } %>>管理员</option>
                        <option value="0" 
                        <% if((edit&&editUser.isAdmin==0)||!edit){ %>
                        selected="selected"
                        <% } %>>普通用户</option>
                    </select>
                </div>
            </div>
            
            <div class="form-group">
                <div class="col-md-10 col-md-offset-2">
                    <% if(edit){ %>
                    <input type="submit" value="保存" class="btn btn-primary" id="submit_btn" onclick ="return checkForm();"><% }else{ %>
                    <input type="submit" value="创建" class="btn btn-primary" id="submit_btn" onclick ="return checkForm();"><% } %>
                    <a href="/admin/user" class="btn btn-default">取消</a>
                </div>
            </div>
        </form>
    </div> 
    <script type="text/javascript">
        function checkForm(){
            var name=$('#name').val().trim();
            var mail=$('#mail').val().trim();
            if(name==""||mail==""){
                return false;
            }
            return true;
        }   
    </script>
<% include ../footer %>